<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>
      Pomelo
    </title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta http-equiv="content-style-type" content="text/css" />
    <meta http-equiv="content-scripte-type" content="text/javascript" />
    <meta name="author" content="netease" />
    <meta name="version" content="1.0" />
    <meta name="keywords" content="pomelo" />
    <link type="text/css" rel="stylesheet" href="css/base.css" />
    <script src="js/lib/build/build.js" type="text/javascript"></script>
    <script type="text/javascript">
      require('boot');
    </script> 
    <script type="text/javascript">
      var pomelo = window.pomelo;
      var host = "127.0.0.1"; //本地服务器
      //host = "120.77.157.99"     //热更新服务器
      //host = "39.108.225.227"      //欢乐赢棋牌服务器
      //host = "39.108.139.132"      //CentOs服务器
      //host = "nnapi.5d8d.com"; //我爱牛牛服务器
      var port = "3010";
      function show() {
          pomelo.request("connector.entryHandler. getNotify",null, function(data) {
              console.log(data)
          });
      }
      pomelo.on("onMessage",function(data) {
        console.log("onMessage")
        console.log(data)
      })
      pomelo.on("onNotify",function(data) {
        console.log("onNotify")
        console.log(data)
      })
      pomelo.on("disconnect",function(data) {
        // body...
        console.log("disconnect")
      })
      pomelo.on("close",function(data) {
        console.log("close")
      })
      pomelo.on("onTips",function(data) {
        console.log("onTips")
        console.log(data)
      })

      //获取战绩
      var getHistory = function(count) {
          pomelo.request("connector.history.getMyHistory", {count : count}, function(data) {
              console.log(data)
            }
          )
      }
      //获取战绩详情
      var getHistoryDetails = function(id) {
          pomelo.request("connector.history.getHistoryDetails", {id : id}, function(data) {
              console.log(data)
            }
          )
      }
      //设置茶楼配置
      var setTeaCfg = function(cfg) {
          pomelo.request("connector.teaHouse.setTeaCfg", {cfg : cfg}, function(data) {
              console.log(data)
            }
          )
      }
      //设置茶楼信息
      var setTeaInfo = function(name,notify) {
          pomelo.request("connector.teaHouse.setTeaInfo", {name : name,notify : notify}, function(data) {
              console.log(data)
            }
          )
      }
      //获取茶楼配置
      var getTeaCfg = function() {
          pomelo.request("connector.teaHouse.getTeaCfg", {}, function(data) {
              console.log(data)
            }
          )
      }

      //申请加入茶楼俱乐部
      var applyJoinClub = function(teaMasterUid){
          pomelo.request("connector.club.applyJoinClub", {teaMasterUid : teaMasterUid}, function(data) {
              console.log(data)
            }
          )
      }
      //获取茶楼俱乐部申请列表
      var getApplyList = function(){
          pomelo.request("connector.club.getApplyList", {}, function(data) {
              console.log(data)
            }
          )
      }
      //同意申请
      var agreeApply = function(playerId){
          pomelo.request("connector.club.agreeApply", {playerId : playerId}, function(data) {
              console.log(data)
            }
          )
      }
      //拒绝申请
      var rejectApply = function(playerId){
          pomelo.request("connector.club.rejectApply", {playerId : playerId}, function(data) {
              console.log(data)
            }
          )
      }
      //获取俱乐部成员列表
      var getClubList = function (uid) {
          pomelo.request("connector.club.getClubList", {uid : uid}, function(data) {
              console.log(data)
            }
          )
      }

      //开启茶楼
      var createTeaHouse = function(){
          pomelo.request("connector.teaHouse.createTeaHouse", {}, function(data) {
              console.log(data)
            }
          )
      }
      //管理员开启茶楼
      var m_createTeaHouse = function(uid,teaId) {
          pomelo.request("connector.teaHouse.m_createTeaHouse", {uid : uid,teaId : teaId}, function(data) {
              console.log(data)
            }
          )
      }
      //关闭茶楼
      var closeTeaHouse = function(uid) {
          pomelo.request("connector.teaHouse.closeTeaHouse", {uid : uid}, function(data) {
              console.log(data)
            }
          )
      }
      //获取茶楼列表
      var getTeaList = function() {
          pomelo.request("connector.teaHouse.getTeaList", {}, function(data) {
              console.log(data)
            }
          )
      }
      //获取我的茶楼
      var getMyTeaHouse = function(uid) {
          pomelo.request("connector.teaHouse.getMyTeaHouse", {}, function(data) {
              console.log(data)
            }
          )
      }
      //获取茶楼排行榜  type : ranking 分数  playCount 参玩次数  winCount  大赢家次数     code : 1  今日   -1  昨日   7  近七天
      var getTeaRankingList = function(type,code) {
          pomelo.request("connector.teaHouse.getTeaRankingList", {type : type,code : code}, function(data) {
              console.log(data)
            }
          )
      }
      //获取茶楼战绩   count : 最新的count条    最小1  最大100   默认选10  
      var getTeaRecord = function(begin,end) {
          pomelo.request("connector.teaHouse.getTeaRecord", {begin : begin,end : end}, function(data) {
              console.log(data)
            }
          )
      }
      //获取茶楼经营数据
      var getRunData = function() {
          pomelo.request("connector.teaHouse.getRunData", {}, function(data) {
              console.log(data)
            }
          )
      }
      //设置默认数据
      var setTeaDefined = function(obj) {
          pomelo.request("connector.teaHouse.setTeaDefined", {obj : obj}, function(data) {
              console.log(data)
            }
          )
      }

      //管理员获取茶楼经营数据
      var m_getRunData = function(uid) {
          pomelo.request("connector.teaHouse.m_getRunData", {uid : uid}, function(data) {
              console.log(data)
            }
          )
      }
      //加入茶楼
      var joinTeaHouse = function(teaId) {
          pomelo.request("connector.teaHouse.joinTeaHouse", {teaId : teaId}, function(data) {
              console.log(data)
            }
          )
      }
      //获取桌子数据
      var getTableInfo = function() {
          pomelo.request("connector.teaHouse.getTableInfo", {}, function(data) {
              console.log(data)
            }
          )
      }
      //离开茶楼
      var leaveTeaHouse = function() {
          pomelo.request("connector.teaHouse.leaveTeaHouse", {}, function(data) {
              console.log(data)
            }
          )
      }
      //加入桌子
      var joinTeaTable = function(tableId) {
          pomelo.request("connector.teaHouse.joinTeaTable", {tableId : parseInt(tableId)}, function(data) {
              console.log(data)
            }
          )
      }
      //修改桌子配置
      var setTeaTableInfo = function(tableId,info) {
        var info =  {gameMode : 4,consumeMode: 2,gameNumber: 10,bankerMode : 1,cardMode : 1,
              playerNumber: 6,gameType : "niuniu",waitMode : 0,special : false,basicType : 0,halfwayEnter : true,allowAllin : true,cuopaiFlag : true}
              // info = false
          pomelo.request("connector.teaHouse.setTeaTableInfo", {tableId : parseInt(tableId),info : info}, function(data) {
              console.log(data)
            }
          )
      }
      //开启新桌子
      var openTable = function() {
          pomelo.request("connector.teaHouse.openTable",{}, function(data) {
              console.log(data)
            }
          )
      }
      //解散桌子
      var dissolvedTable = function(tableId) {
          pomelo.request("connector.teaHouse.dissolvedTable",{tableId : tableId}, function(data) {
              console.log(data)
            }
          )
      }
      var join = function(roomId) {
          pomelo.request("connector.entryHandler.sendData", {"code" : "join","params" : {roomId : roomId}}, function(data) {
              console.log("flag is : ")
              console.log(data)
            }
          );
      }
      //管理员功能 
      //开启维护
      var beginMaintain = function() {
          pomelo.request("connector.entryHandler.sendData", {"code" : "superOperation","params" : {cmd : "beginMaintain"}}, function(data) {
              console.log("flag is : ")
              console.log(data)
            }
          );
      }
      //关闭维护
      var stopMaintain = function() {
          pomelo.request("connector.entryHandler.sendData", {"code" : "superOperation","params" : {cmd : "stopMaintain"}}, function(data) {
              console.log("flag is : ")
              console.log(data)
            }
          );
      }
      //获取房间列表
      var getRooms = function() {
          pomelo.request("connector.entryHandler.sendData", {"code" : "superOperation","params" : {cmd : "getRooms"}}, function(data) {
              console.log("flag is : ")
              console.log(data)
            }
          );
      }
      //关闭房间
      var finishRoom = function(roomId) {
          pomelo.request("connector.entryHandler.sendData", {"code" : "superOperation","params" : {cmd : "finishRoom",roomId : roomId}}, function(data) {
              console.log("flag is : ")
              console.log(data)
            }
          );
      }
      //关闭全部房间
      var finishAllRoom = function() {
          pomelo.request("connector.entryHandler.sendData", {"code" : "superOperation","params" : {cmd : "finishAllRoom"}}, function(data) {
              console.log("flag is : ")
              console.log(data)
            }
          );
      }

      //抽奖
      var lottery = function() {
          pomelo.request("connector.award.lottery", {}, function(data) {
              console.log(data)
            }
          )
      }
      //添加机器人数据
      var addRobotLottery = function(index) {
          pomelo.request("connector.award.addRobotLottery", {"index" : index}, function(data) {
              console.log(data)
            }
          )
      }
      //自动机器人
      var setRobotState = function(state,table,time) {
          pomelo.request("connector.award.setRobotState", {"state" : state,"table" : table,"time" : time}, function(data) {
            }
          )
      }
      //设置库存表
      var setLotteryInventoryItem = function(data) {
          //itemId value
          pomelo.request("connector.award.setLotteryInventoryItem", {"data" : data}, function(data) {
              console.log(data)
            }
          )
      }
      //设置转盘表
      var setLotteryTable = function(data) {
          pomelo.request("connector.award.setLotteryTable", {"data" : data}, function(data) {
              console.log(data)
            }
          )
      }
      //设置物品状态 0 : 未发送   10:已发送完成
      var sendAwardState = function(uid,orderNumber,state) {
          pomelo.request("connector.award.sendAwardState", {"uid" : uid,"orderNumber" : orderNumber,"state" : state}, function(data) {
              console.log(data)
            }
          )
      }
      //获取抽奖次数列表
      var getLotteryCountList = function() {
          pomelo.request("connector.award.getLotteryCountList", {}, function(data) {
              console.log(data)
            }
          )
      }
      //添加抽奖次数(仅管理员)
      var addLotteryCount = function(uid,count) {
          pomelo.request("connector.award.addLotteryCount", {"uid" : uid,"count" : count}, function(data) {
              console.log(data)
            }
          )
      }
      //分享领取次数
      var shareAward = function() {
          pomelo.request("connector.award.shareAward", {}, function(data) {
              console.log(data)
            }
          )
      }
      //获取重要物品抽奖记录
      var getImportanceAwardList = function() {
          pomelo.request("connector.award.getImportanceAwardList", {}, function(data) {
              console.log(data)
            }
          )
      }
      //获取我的奖励背包
      var getMyLotteryAward = function() {
          pomelo.request("connector.award.getMyLotteryAward", {}, function(data) {
              console.log(data)
            }
          )
      }

      //获取奖品表（转盘内容）
      var getLotteryTable = function(a) {
          pomelo.request("connector.award.getLotteryTable", {}, function(data) {
              console.log(data)
              a = data
            }
          )
      }
      //获取奖品库存（仅管理员）
      var getLotteryInventory = function(a) {
          pomelo.request("connector.award.getLotteryInventory", {}, function(data) {
              console.log(data)
              a = data
            }
          )
      }
      //获取已获奖记录(仅管理员)
      var getLotteryAwardList = function() {
          pomelo.request("connector.award.getLotteryAwardList", {}, function(data) {
              console.log(data)
            }
          )
      }
      //获取抽奖记录(仅管理员)
      var getLotteryHistory = function() {
          pomelo.request("connector.award.getLotteryHistory", {}, function(data) {
              console.log(data)
            }
          )
      }
      //获取我的抽奖次数
      var getLotteryCount = function() {
          pomelo.request("connector.award.getLotteryCount", {}, function(data) {
              console.log(data)
            }
          )
      }
      var send = function(code,msg) {
          pomelo.request("connector.entryHandler.sendData", {"code" : code,"params" : msg}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }
      var sendBet = function(bet) {
          pomelo.request("connector.entryHandler.sendData", {"code" : "useCmd","params" : {"cmd" : "bet","bet" : bet}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }

      var robBanker = function(num) {
          pomelo.request("connector.entryHandler.sendData", {"code" : "useCmd","params" : {"cmd" : "robBanker","num" : num}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      } 
      var mbet = function(bet) {
          pomelo.request("connector.entryHandler.sendData", {"code" : "useCmd","params" : {"cmd" : "bet","bet" : bet}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }    
      var allIn = function() {
          pomelo.request("connector.entryHandler.sendData", {"code" : "useCmd","params" : {"cmd" : "allIn"}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }  
      var sendGiveUp = function(bet) {
          pomelo.request("connector.entryHandler.sendData", {"code" : "useCmd","params" : {"cmd" : "giveUp"}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }
      var compare = function(target) {
          pomelo.request("connector.entryHandler.sendData", {"code" : "useCmd","params" : {"cmd" : "compare","target" : target}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }
      var compare = function(target) {
          pomelo.request("connector.entryHandler.sendData", {"code" : "useCmd","params" : {"cmd" : "compare","target" : target}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }
      var newRoom = function() {
          pomelo.request("connector.entryHandler.sendData", {"code" : "newRoom","params" : {gameMode : 4,
            consumeMode: 1,gameNumber: 10,bankerMode : 1,cardMode : 1,playerNumber: 6,gameType : "niuniu",waitMode : 0}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }
      var zhajinniu = function() {
          pomelo.request("connector.entryHandler.sendData", {"code" : "newRoom","params" : {gameMode : 4,
            consumeMode: 1,gameNumber: 10,bankerMode : 1,cardMode : 1,playerNumber: 6,basic : 1,gameType : "zhajinniu"}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }
      var agency = function(argument) {
          pomelo.request("connector.entryHandler.sendData", {"code" : "agency","params" : {gameMode : 4,
            consumeMode: 1,gameNumber: 10,bankerMode : 1,cardMode : 1,playerNumber: 6,basic : 1 ,gameType : "zhajinniu"}}, function(data,msg) {
              console.log("flag is : "+data.flag)
              console.log(data.msg)
            }
          );          
      }
      var login = function(uid) {
        pomelo.init({
          host: host,
          port: port,
          log: true
        }, function() {
          pomelo.request("connector.entryHandler.enter", {"uid" : uid}, function(data) {

          });
        });          
      }
      var vlogin = function(uid) {
        queryEntry(uid,function(host, port) {
          pomelo.init({
            host: host,
            port: port,
            log: true
          }, function() {
            var route = "connector.entryHandler.visitorEnter";
            pomelo.request(route,{"uid" : uid}, function(data) {
              console.log(data)
              if(data.error) {
                console.log(data)
                return;
              }
            });
          });
        });        
      }
      // query connector
      var queryEntry = function(uid,callback) {
        var route = 'gate.gateHandler.queryEntry';
        pomelo.init({
          host: host,
          port: "3900",
          log: true
        }, function() {
          pomelo.request(route, {
            uid: uid
          }, function(data) {
            pomelo.disconnect();
            if(data.code === 500) {
              console.log(data)
              return;
            }
            callback(host, data.port);
          });
        });
      };
      var test = function() {
          pomelo.request("connector.entryHandler.test",null,null);
      }
      var finish = function() {
          pomelo.request("connector.entryHandler.sendFrame", {"code" : "finish"},null, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }
      var agreeFinish = function() {
          pomelo.request("connector.entryHandler.sendFrame", {"code" : "agreeFinish"},null, function(data) {
              console.log("flag is : "+data.flag)
            }
          )
      }
      var refuseFinish = function() {
          pomelo.request("connector.entryHandler.sendFrame", {"code" : "refuseFinish"},null, function(data) {
              console.log("flag is : "+data.flag)
            }
          )
      }
      var quit = function() {
          pomelo.request("connector.entryHandler.sendFrame", {"code" : "userQuit"},null, function(data) {
              console.log("flag is : "+data.flag)
            }
          )
      }
      var agencyFinish = function(roomId) {
          pomelo.request("connector.entryHandler.sendFrame", {"code" : "agencyFinish","params" : {"roomId" : roomId}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          )
      }
      var giveDiamond = function(target,diamond) {
          pomelo.request("monitor.handle.giveDiamond", {target : target,diamond : diamond}, function(data) {
              console.log(data)
          })
      }
      var queryNickName = function(uid) {
          pomelo.request("monitor.handle.queryNickName", {uid : uid}, function(data) {
              console.log(data)
          })
      }
      var getUsers = function() {
          pomelo.request("connector.monitor.onlineUser",null, function(data) {
              console.log(data)
          })
      }
      var getAgencyList = function() {
          pomelo.request("connector.monitor.getAgencyList",null, function(data) {
              console.log(data)
          })
      }
      var init = function() {
        pomelo.init({
          host: host,
          port: port,
          log: true
        }, function() {
        })
      }


      var getAgencyRoom = function() {
          pomelo.request("connector.entryHandler.getAgencyRoom",null, function(data) {
              console.log(data)
          }); 
      }

      var mroom = function() {
          pomelo.request("connector.entryHandler.sendData", {"code" : "newRoom","params" : {
            consumeMode: 1,gameNumber: 10,cardMode : 1,basic : 1,gameType : "mingpaiqz"}}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }
      var getTick = function() {
          pomelo.request("connector.entryHandler.getTicket",null, function(data) {
              console.log(data)
          });
      }
      var getRoomInfo = function(roomId) {
          pomelo.request("connector.entryHandler.sendData",{"code" : "getRoomInfo","params" : {"roomId" : roomId}}, function(data) {
              console.log(data)
          });        
      }
      //申请验证码
      var sendCaptcha = function(phone) {
          pomelo.request("connector.identity.sendCaptcha", {"phone" : phone}, function(data) {
              console.log("flag is : "+data.flag)
            }
          );
      }
      //注册账号
      var register = function(phone,password,code,referrer) {
          pomelo.request("connector.identity.register", {"phone" : phone,"password" : password,"code" : code,
            "referrer" : referrer}, function(data) {
              console.log(data)
            }
          );
      }
      //修改密码
      var changePassword = function(phone,password,code) {
          pomelo.request("connector.identity.changePassword", {"phone" : phone,"password" : password,"code" : code}, function(data) {
              console.log(data)
            }
          );
      }
      //手机登录
      var phoneLogin = function(phone,password) {
        queryEntry("",function(host, port) {
          pomelo.init({
            host: host,
            port: port,
            log: true
          }, function() {
            pomelo.request("connector.entryHandler.phoneLogin", {"phone" : phone,"password" : password}, function(data) {
                console.log(data)
              }
            );
          });
        });
      }
      //修改昵称
      var changeNickname = function(nickname) {
          pomelo.request("connector.identity.changeNickname", {"nickname" : nickname}, function(data) {
              console.log(data)
            }
          );
      }
      //修改头像
      var changeHeadType = function(headType) {
          pomelo.request("connector.identity.changeHeadType", {"headType" : headType}, function(data) {
              console.log(data)
            }
          );
      }
      //增加钻石
      var addDiamond = function(uid,value) {
          pomelo.request("connector.admin.addDiamond", {uid : uid,value : value}, function(data) {
              console.log(data)
            }
          );
      }
      //获取玩家信息
      var getPlayerInfoByUid = function(uid) {
          pomelo.request("connector.admin.getPlayerInfoByUid", {uid : uid}, function(data) {
              console.log(data)
            }
          );
      }
    </script>
  </head>
  <body>
    <div class="g-doc">
      <div class="g-banner" style="border:none">
        <div class="logo">
          <div class="img"></div>
        </div>
      </div>
      <div class="g-background">
        <div class="g-content">
          Welcome to Pomelo
        </div>
      </div>
      <div class="g-link">
        Home:
        <a href="https://github.com/NetEase/pomelo">https://github.com/NetEase/pomelo</a>
      </div>
      <div class="g-button">
        <input id="test" type="button" value="Test Game Server" onclick="show()"/>
      </div>
    </div>
  </body>
</html>
